<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<view class="nav-bar">
			<uni-icons type="back" size="30" color="#fff" @click="goBack" />
			<text class="title">消息</text>
			<view class="right-icons">
			</view>
		</view>
		<!-- 消息列表卡片 -->
		<view class="card">
			<view v-for="(item, index) in msgList" :key="index">
				<view class="msg-item">
					<view class="msg-header">
						<text class="msg-title">{{item.title}}</text>
						<text class="msg-time">{{ item.time }}</text>
					</view>
					<text class="msg-content">{{item.content}}</text>
				</view>
				<view v-if="index !== msgList.length - 1" class="divider"></view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../uitls/request';
	export default {
		data() {
			return {
				userInfo: {},
				msgList: [
					// {
					// 	title: "支付成功通知",
					// 	content: "订单编号为：*******，消费****元",
					// 	time: "2000.02.02",
					// },
					// {
					// 	title: "支付成功通知",
					// 	content: "订单编号为：*******，消费****元",
					// 	time: "2000.02.02",
					// },
					// {
					// 	title: "支付成功通知",
					// 	content: "订单编号为：*******，消费****元",
					// 	time: "2000.02.02",
					// }
				]
			}
		},
		methods: {
			goBack() {
				uni.navigateBack();
			}
		},
		onLoad() {
			this.userInfo = uni.getStorageSync('userInfo');
			const that = this
			// console.log(this.userInfo.id);
			request({
				url: '/notice/message/getMessageByUserId',
				method: 'GET',
				data: {
					userId: this.userInfo.id,
				},
				success(res) {
					const result = res.data;
					if (result.code == 200) {
						// console.log(result);
						that.msgList = result.data;
						console.log(that.msgList)
					}
				}
			})
		}
	}
</script>

<style>
	.container {
		/* #ifdef MP-WEIXIN */
		margin-top: 70rpx;
		/* #endif */
		background: linear-gradient(180deg, #2e8bff, #3ca7fa);
		background-size: 100% 35%;
		background-repeat: no-repeat;
		min-height: 100vh;
	}

	.nav-bar {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 40rpx 30rpx 20rpx 30rpx;
		color: #fff;
	}

	.title {
		font-size: 40rpx;
	}

	.right-icons {
		display: flex;
		gap: 20rpx;
		width: 45rpx;
	}

	.card {
		background: #fff;
		margin: 30rpx 3%;
		border-radius: 30rpx;
		padding: 20rpx 0;
		box-shadow: 0 2rpx 8rpx #eee;
	}

	.msg-item {
		padding: 30rpx 40rpx 20rpx 40rpx;
	}

	.msg-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.msg-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #222;
	}

	.msg-time {
		color: #bbb;
		font-size: 26rpx;
	}

	.msg-content {
		color: #333;
		font-size: 28rpx;
		margin-top: 10rpx;
		display: block;
	}

	.divider {
		height: 2rpx;
		background: #f2f2f2;
		margin: 0 40rpx;
	}
</style>